package ch.selise.archtool.ui.controller;

import ch.selise.archtool.lib.HouseBuilder;
import ch.selise.archtool.lib.HouseBuildingCompany;
import ch.selise.archtool.lib.builders.MultiStoryHouseBuilder;
import ch.selise.archtool.lib.builders.SimpleHouseBuilder;
import ch.selise.archtool.lib.product.House;

public class MainUIController {
	
	public static final String SIMPLE = "simple";
	public static final String MULTI = "multi";
	
	private HouseBuildingCompany company = new HouseBuildingCompany();
	private HouseBuilder builder;
	private House house;
	
	public House getHouse(){return this.house;}
	
	public void getBuilder(String builder){
		//HouseBuilder houseBuilder = null;
		if(builder.equals(MULTI)){
			this.builder = new MultiStoryHouseBuilder(2);
		}
		else {
			this.builder = new SimpleHouseBuilder();
		}
		
		//return houseBuilder;
	}
	
	public void buildHouse() throws Exception {
		if(house != null){
			throw new Exception("Already build.");
		}
		if(builder == null){
			throw new Exception("Choose a builder.");
		}
		house = company.build(builder);
		
		System.out.println(house);
	}
	
	

}
